<?php
/**
 * Created by PhpStorm.
 * User: Zhoujinda
 * Date: 2016/3/10
 * Time: 11:08
 */
namespace Test\Controller;

use Common\Api\BoyeServiceApi;

class TestOrdersController extends TestController{

    public function index(){
        $this->display();
    }

    public function query(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'curpage'=> I('post.curpage',''),
                'pagesize'=> I('post.pagesize',''),
                'status'=> I('post.status',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_query',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function detail(){

        if(IS_POST){

            $data = array(
                'id'=> I('post.id',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_detail',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function add(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'cart_ids'=> I('post.cart_ids',''),
                'idcode'=> I('post.idcode',''),
                'note'=> I('post.note',''),
                'address_id'=> I('post.address_id',''),
                'from'=> I('post.from',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_add',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function sureorder(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'order_code'=> I('post.order_code',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_sureorder',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function qxorder(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'order_code'=> I('post.order_code',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_qxorder',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function turnback(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'order_code'=> I('post.order_code',''),
                'reason'=> I('post.reason',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_turnback',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }
    public function afterSale(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'order_code'=> I('post.order_code',''),
                'reason'=> I('post.reason',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_afterSale',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function pay(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'order_id'=> I('post.order_id',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_pay',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function express(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'order_code'=> I('post.order_code',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_express',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function Refund(){

        if(IS_POST){

            $data = array(
                'order_code'=> I('post.order_code',''),
                'reason'=> I('post.reason',''),
                'money'=> I('post.money',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Orders_Refund',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }


    private function parseResult($result){
        header('Content-type:text/html;charset=utf-8');
        echo "解密后数据：";
        dump($result);
    }

}